package com.xjaq.dify.http;

import com.github.lianjiatech.retrofit.spring.boot.annotation.Intercept;
import com.github.lianjiatech.retrofit.spring.boot.annotation.RetrofitClient;
import com.xjaq.dify.entity.DifyRequest;
import com.xjaq.dify.entity.TextToAudioRequest;
import com.xjaq.dify.interceptor.DifyInterceptor;
import com.xjaq.dify.interceptor.UploadInterceptor;
import okhttp3.MultipartBody;
import okhttp3.RequestBody;
import okhttp3.ResponseBody;
import retrofit2.Call;
import retrofit2.http.*;

@RetrofitClient(baseUrl = "${dify.base-url}",readTimeoutMs = 30000, connectTimeoutMs = 100000, writeTimeoutMs = 100000)
@Intercept(handler = UploadInterceptor.class)
public interface UploadHttpApi {
//    @Headers({"Content-Type: multipart/form-data"
//            ,"Authorization: Bearer ${dify.api-key}"
//            ,"Accept: text/event-stream"
//            , "Host: ${dify.host}"})
    @POST("files/upload")
    Call<ResponseBody> uploadFile(@Body DifyRequest difyRequest);

    @Multipart
    @POST("audio-to-text")
    Call<ResponseBody> audioToText(
            @Part MultipartBody.Part file,
            @Part("user") RequestBody user
    );
    
    @Multipart
    @POST("files/upload")
    Call<ResponseBody> uploadFile(
            @Part MultipartBody.Part file,
            @Part("user") RequestBody user
    );

}
